package com.awphone.data;

import com.awphone.data.constant.EObjectType;
import com.awphone.data.constant.PhoneConst;

import javax.persistence.*;

/**
 * @author a_polyakov
 * Date: 03.03.13
 * Time: 22:35
 * Телефонный номер
 */
@Entity
@Table(schema = PhoneConst.SCHEMA_NAME, name = PhoneConst.TABLE_NAME)
public class Phone extends AbstractObject {
    /**
     * Префикс
     */
    private NXX nxx;
    /**
     * Улица
     */
    private Street street;
    /**
     * Номер дома, сектор, квартира
     */
    private String building;
    /**
     * Количество просмотров
     */
    private Integer countView;
    /**
     * Широта
     */
    private Double gpsLatitude;

    /**
     * Долгота
     */
    private Double gpsLongitude;

    {
        setObjectType(EObjectType.PHONE);
    }

    public Phone() {
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = PhoneConst.S_NXX, nullable = false, updatable = false)
    public NXX getNxx() {
        return nxx;
    }

    public void setNxx(NXX nxx) {
        this.nxx = nxx;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = PhoneConst.S_STREET, nullable = true)
    public Street getStreet() {
        return street;
    }

    public void setStreet(Street street) {
        this.street = street;
    }

    @Column(name = PhoneConst.S_BUILDING, nullable = true)
    public String getBuilding() {
        return building;
    }

    public void setBuilding(String building) {
        this.building = building;
    }

    @Column(name = PhoneConst.S_COUNT_VIEW, nullable = false)
    public Integer getCountView() {
        return countView;
    }

    public void setCountView(Integer countView) {
        this.countView = countView;
    }

    @Column(name = PhoneConst.S_GPS_LATITUDE, nullable = false)
    public Double getGpsLatitude() {
        return gpsLatitude;
    }

    public void setGpsLatitude(Double gpsLatitude) {
        this.gpsLatitude = gpsLatitude;
    }

    @Column(name = PhoneConst.S_GPS_LONGITUDE, nullable = false)
    public Double getGpsLongitude() {
        return gpsLongitude;
    }

    public void setGpsLongitude(Double gpsLongitude) {
        this.gpsLongitude = gpsLongitude;
    }
}
